<%--
  @author Kusal Samarakoon
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/dateSelector.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/validate.js"></script>

<script type="text/javascript">

     function validateDetails() {

     $("#payment-form").validate();

     $('#billId').rules("add", {
      required: true
     });
     $('#billDate').rules("add", {
     isDateFormated: true,
     required: true
     });

     $('#rentalCashAmnt').rules("add", {
     required: true
     });

     $('#taxCashAmnt').rules("add", {
     required: true
     });


     }


    $(function () {
        $("#billDate").datepicker();
        $("#checkDate").datepicker();
        $("#mOrderDate").datepicker();


        var paymentCashHtml = $('#paymentCash').html();
        var paymentChequeHtml = $('#paymentCheque').html();
        var paymentMoneyOrderHtml = $('#paymentMoneyOrder').html();

        $('#paymentType3').bind('click', function () {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html(' ');
            $('#paymentMoneyOrder').html('');
        });

        $('#paymentType2').bind('click', function () {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html(' ');
            $('#paymentMoneyOrder').html(paymentMoneyOrderHtml);
        });

        $('#paymentType0').bind('click', function () {
            $('#paymentCash').html(paymentCashHtml);
            $('#paymentCheque').html(' ');
            $('#paymentMoneyOrder').html(' ');
        });

        $('#paymentType1').bind('click', function () {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html(paymentChequeHtml);
            $('#paymentMoneyOrder').html(' ');
        });

        if ($('#paymentType2').is(':checked')) {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html(' ');
            $('#paymentMoneyOrder').html(paymentMoneyOrderHtml);

        } else if ($('#paymentType0').is(':checked')) {
            $('#paymentCash').html(paymentCashHtml);
            $('#paymentCheque').html(' ');
            $('#paymentMoneyOrder').html(' ');

        } else if ($('#paymentType1').is(':checked')) {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html(paymentChequeHtml);
            $('#paymentMoneyOrder').html(' ');
        } else if($('#paymentType3').is(':checked')) {
            $('#paymentCash').html(' ');
            $('#paymentCheque').html('');
            $('#paymentMoneyOrder').html(' ');
        }
    });
</script>

<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="paymentModule.do">
        <span><img src="${pageContext.request.contextPath}/images/payment.png" alt="Land Registration">
            <s:label value="%{getText('land_payments_module.label')}"/></span>
    </s:a>
    <span class="module-title-breaker"> > </span>
    <s:a href="detailForm.do">
        <span><img src="${pageContext.request.contextPath}/images/monthly-rent.png"
                   alt="Enter Detailed Land Information">
            <s:label value="Annual Rent"/></span>
    </s:a>
    <div id="back-button" align="right">
        <s:form><s:submit value="%{getText('back_btn.label')}" action="landRegistrationModule"/></s:form>
    </div>
</div>
<div id="detail-land-update-list">
    <div class="page-title">
        <h2><s:label value="Payment Invoice Edit"/></h2>
    </div>
    <s:if test="hasActionErrors() || hasActionMessages()">
        <div id="message-box" class="message-box">
            <div class="action-msg"><s:actionmessage/></div>
            <div class="action-err"><s:actionerror/></div>
        </div>
    </s:if>

    <s:form method="POST" id="payment-form" name="payment-form" enctype="multipart/form-data" >

        <div id="pay-slip">
            <div id="personal-details">

                <table>
                    <tr>
                        <td>File Number :</td>
                        <td colspan="3"><s:label value="%{alienation.land.landFileNumber}"/></td>
                    </tr>

                    <tr>
                        <td>Lease Number :</td>
                        <td colspan="3"><s:label value="%{alienation.leaseDetail.leaseNo}"/></td>
                    </tr>


                </table>

                <table class="width-100">
                    <tr>
                        <td align="center" colspan="4">
                            <s:radio id="paymentType" name="payment.paymentType"
                                     list="#@java.util.HashMap@{'3':'Undefine','2':'Money Order', '1':'Cheque','0':'Cash'}"
                                     value="%{payment.paymentType}"/>
                        </td>
                    </tr>
                </table>
                <table id="paymentCash" class="width-100">
                    <tr>
                        <td>Bill No</td>
                        <td><s:textfield id="billId" name="payment.receiptReferenceNo"
                                         cssClass="width-200-px"/></td>
                        <td>Billing Date</td>
                        <td><s:textfield id="billDate" name="payment.billingDate"
                                         onclick="selectDate('billDate')"
                                         onKeyPress="return dateNumbersOnly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>
                    <tr>
                        <td colspan="4">Payment Info :</td>
                    </tr>
                    <tr>
                        <td>Rental (Rs:)</td>
                        <td><s:textfield id="rentalCashAmnt" name="payment.rentalAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                        <td>Tax (Rs:)</td>
                        <td><s:textfield id="taxCashAmnt" name="payment.taxAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>


                </table>
                <table id="paymentCheque" class="width-100">
                    <tr>
                        <td>Cheque No</td>
                        <td><s:textfield id="billId" name="payment.receiptReferenceNo"
                                         cssClass="width-200-px"/></td>
                        <td>Cheque Date</td>
                        <td><s:textfield id="billDate" name="payment.billingDate"
                                         onclick="selectDate('billDate')"
                                         onKeyPress="return dateNumbersOnly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>
                    <tr>
                        <td colspan="4">Payment Info :</td>
                    </tr>
                    <tr>
                        <td>Rental (Rs:)</td>
                        <td><s:textfield id="rentalCashAmnt" name="payment.rentalAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                        <td>Tax (Rs:)</td>
                        <td><s:textfield id="taxCashAmnt" name="payment.taxAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>

                </table>
                <table id="paymentMoneyOrder" class="width-100">
                    <tr>
                        <td>Money Order No</td>
                        <td><s:textfield id="billId" name="payment.receiptReferenceNo"
                                         cssClass="width-200-px"/></td>
                        <td>Money Order Date</td>
                        <td><s:textfield id="billDate" name="payment.billingDate"
                                         onclick="selectDate('billDate')"
                                         onKeyPress="return dateNumbersOnly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>
                    <tr>
                        <td colspan="4">Payment Info :</td>
                    </tr>
                    <tr>
                        <td>Rental (Rs:)</td>
                        <td><s:textfield id="rentalCashAmnt" name="payment.rentalAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                        <td>Tax (Rs:)</td>
                        <td><s:textfield id="taxCashAmnt" name="payment.taxAmount"
                                         onKeyPress="return numbersonly(event,true)"
                                         cssClass="width-200-px"/></td>
                    </tr>


                </table>

                <table>
                    <tr>
                        <td>Total Rental (Rs:)</td>
                        <td colspan="3"><s:label id="totalPayable" value="%{alienation.leaseDetail.totalPayable}"/></td>
                    </tr>

                    <tr>
                        <td>Arrears Rental (Rs:)</td>
                        <td colspan="3"><s:label id="arrearsAmount"
                                                 value="%{alienation.leaseDetail.arrearsAmount}"/></td>
                    </tr>

                    <tr>
                        <td>Arrears Tax (Rs:)</td>
                        <td colspan="3"><s:label id="arrearsTax" value="%{alienation.leaseDetail.arrearsTax}"/></td>
                    </tr>
                </table>

                    <s:submit cssClass="cancel" action="home" value="Edit" onclick="javascript:return validateDetails();"/>


                <s:submit cssClass="cancel" action="home" value="Cancel"/>
            </div>
        </div>
        <s:hidden id="alienationId" name="alId"/>
    </s:form>
</div>


<%-- Localization text for java script generated text --%>
<%--<s:hidden id="ref" value="%{getText('reference_no.label')}"/>--%>
<s:hidden id="ref" value="%{getText('reference_no.label')}"/>
<s:hidden id="lname" value="%{getText('name_of_the_land.label')}"/>
<s:hidden id="plan" value="%{getText('plan_no.label')}"/>
<s:hidden id="lot" value="%{getText('lot_no.label')}"/>
<s:hidden id="extent" value="%{getText('extent_perches.label')}"/>
<s:hidden id="action" value="%{getText('action.label')}"/>
<s:hidden id="reject_tooltip" value="%{getText('reject_tooltip')}"/>
<s:hidden id="add_detail_tooltip" value="%{getText('add_detail_tooltip')}"/>
<s:hidden id="edit_tooltip" value="%{getText('edit_tooltip')}"/>
<s:hidden id="undefined" value="%{getText('undefined.label')}"/>
<s:hidden id="pay_tooltip" value="%{getText('pay_tooltip')}"/>

<%-- Localization text for search form --%>
<s:hidden id="land_file_no" value="%{getText('land_file_no.label')}"/>
<s:hidden id="lease_no" value="%{getText('lease_no.label')}"/>

<%-- Localization text for data tables --%>
<s:hidden id="display" value="%{getText('display.label')}"/>
<s:hidden id="records" value="%{getText('records.label')}"/>
<s:hidden id="search" value="%{getText('search.label')}"/>
<s:hidden id="no-record" value="%{getText('no_record.label')}"/>
<s:hidden id="showing" value="%{getText('showing.label')}"/>
<s:hidden id="to" value="%{getText('to.label')}"/>
<s:hidden id="of" value="%{getText('of.label')}"/>
<s:hidden id="entries" value="%{getText('entries.label')}"/>
<s:hidden id="first" value="%{getText('first.label')}"/>
<s:hidden id="last" value="%{getText('last.label')}"/>
<s:hidden id="next" value="%{getText('next.label')}"/>
<s:hidden id="previous" value="%{getText('previous.label')}"/>

<s:hidden id="maxRows" name="@lk.icta.common.AppConstants@MAX_ROWS_PER_PAGE_STRING"/>
<s:hidden id="select" value="%{getText('select.label')}"/>
<s:hidden id="all" value="%{getText('all.label')}"/>
<s:hidden id="userGroup" name="#session.userGroup"/>
